package com.zw.yzk.kabu.mapper;

import com.zw.yzk.kabu.data.network.entity.SkinCategoryListEntity;
import com.zw.yzk.kabu.data.network.entity.SkinCoverEntity;
import com.zw.yzk.kabu.model.SkinCategoryModel;
import com.zw.yzk.kabu.model.SkinModel;

import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by skydar on 2017/4/14.
 */

public class SkinCategoryMapper {

    @Inject
    public SkinCategoryMapper() {

    }

    public SkinCategoryModel transfer(SkinCategoryListEntity.SkinCategory category) {
        SkinCategoryModel model = new SkinCategoryModel();
        model.setCategoryId(category.categoryId);
        model.setSubject(category.subject);
        model.setTotal(category.total);
        List<SkinModel> skinModels = new ArrayList<>();
        for(int i=0; i<category.skins.size(); i++){
            SkinModel skin = new SkinModel();
            SkinCoverEntity entity = category.skins.get(i);
            skin.setCoverPath(entity.coverPath);
            skin.setId(entity.id);
            skin.setName(entity.name);
            skinModels.add(skin);
        }
        model.setSkinModel(skinModels);

        return model;
    }

    public List<SkinCategoryModel> transfer(SkinCategoryListEntity entity) {
        List<SkinCategoryModel> models = new ArrayList<>();
        if(entity.result.skinPackageList == null || entity.result.skinPackageList.isEmpty()) {
            return models;
        }
        for(SkinCategoryListEntity.SkinCategory category : entity.result.skinPackageList) {
            models.add(transfer(category));
        }
        return models;
    }
}
